package com.jt.zcdemo;



import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>Student此类用于：学生信息实体 </p>
 * <p>@author：hujm</p>
 * <p>@date：2023年01月12日 18:36</p>
 * <p>@remark：注意此处加了Lombok的@Data、@AllArgsConstructor、@NoArgsConstructor注解，所以此类的Getter/Setter/toString/全参构造/无参构造都省略 </p>
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Student implements Comparable<Student> {

    private String name;

    private Boolean sex;

    private Integer age;

    private Double height;

    private LocalDate birthday;

    @Override
    public int compareTo(Student student) {
        return this.age.compareTo(student.getAge());
    }

    @Override
    public String toString() {
        return String.format("%s\t\t%s\t\t%s\t\t%s\t\t%s",
                this.name, this.sex.toString(), this.age.toString(), this.height.toString(), birthday.toString());
    }

    /**
     * 打印学生信息的静态方法
     *
     * @param studentList 学生信息列表
     */
    public static void printStudentList(List<Student> studentList) {
        System.out.println("【姓名】\t【性别】\t【年龄】\t\t【身高】\t\t【生日】");
        System.out.println("-----------------------------------------------------");
        studentList.forEach(s -> System.out.println(s.toString()));
        System.out.println(" ");
    }
}